package com.example.mylibrarybase.yumengmeng02.ui;

import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.mylibrarybase.R;
import com.example.mylibrarybase.bar.initAction_Bar;
import com.example.mylibrarybase.base.baseui.BaseActivity;
import com.example.mylibrarybase.utils.LogUtils;
import com.example.mylibrarybase.yumengmeng02.bean.UploadFile_02;
import com.example.mylibrarybase.yumengmeng02.imageviewer.adapter.MyShowbigImageAdapteryuanshi_02;
import com.example.mylibrarybase.yumengmeng02.view.imagelochViewPager_02;

import java.util.ArrayList;
import java.util.List;

public class photoView_02 extends BaseActivity {

    //  //模式 0 是本地模式  1是网络模式
    public static int LOCAL_MODE = 0;
    public static int NET_MODE = 1;
    //如果传过来集合你得告诉我你点了第几号
    int postion = 0;

    public int mode =0;
    //自定义的ViewPager
   // private imagelochViewPager vp_lochshowbigImage = null;
    //装ViewPager的适配器
  //  private MyShowbigImageAdapteryuanshi_02 myShowbigImageAdapter =null;
    private List<UploadFile_02> localList;
    private Bundle extras;
    private ArrayList<String> networkList;
    private ArrayList<String> imagePath;
    private MyShowbigImageAdapteryuanshi_02 myShowbigImageAdapter;
    private imagelochViewPager_02 vp_lochshowbigImage;
    private initAction_Bar mBase_action_bar;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        initView();
        getBox();
    }

    @Override
    public int getlayouXML() {
        return R.layout.activity_photo_view_02;
    }

    @Override
    public void onResume() {
        super.onResume();
//        MobclickAgent.onPageStart("photoView1"); //统计页面(仅有Activity的应用中SDK自动调用，不需要单独写。"SplashScreen"为页面名称，可自定义)
//        MobclickAgent.onResume(this);          //统计时长
    }
    @Override
    public void onPause() {
        super.onPause();
//        MobclickAgent.onPageEnd("photoView1"); // （仅有Activity的应用中SDK自动调用，不需要单独写）保证 onPageEnd 在onPause 之前调用,因为 onPause 中会保存信息。"SplashScreen"为页面名称，可自定义
//        MobclickAgent.onPause(this);
    }




    private void getBox() {
        extras = getIntent().getExtras();
        postion = extras.getInt("postion");
        LogUtils.i("之前那个页面点选的号码是" + postion);
        //获取本地图片的集合
        localList = (List<UploadFile_02>) extras.getSerializable("list");
        //获取网络图片的集合
        networkList = extras.getStringArrayList("arrayList");
        initData();
    }
    public void initData() {

        imagePath = new ArrayList<>();
        //如果localList 有值说明是本地模式
        if (localList != null) {
            //本地的
            for (int i = 0; i < localList.size(); i++) {
                String localPath = localList.get(i).getFile_path();
                imagePath.add(localPath);
            }
            mode = LOCAL_MODE;
            LogUtils.i("本地过来的" + imagePath);
        }
        if (networkList != null) {
            for (int i = 0; i < networkList.size(); i++) {
                String s = networkList.get(i);
                // imagePath.add(NetMan.BASE_URL + s);
            }
            LogUtils.i("网络过来的" + imagePath);
            mode = NET_MODE;
        }
        initAdapter();
    }
    public void initAdapter() {
        myShowbigImageAdapter = new MyShowbigImageAdapteryuanshi_02(this, postion, mode);

        myShowbigImageAdapter.setData(imagePath);
        vp_lochshowbigImage.setAdapter(myShowbigImageAdapter);
        vp_lochshowbigImage.setVisibility(View.VISIBLE);
        vp_lochshowbigImage.setCurrentItem(postion);

    }
    public void initView() {
       vp_lochshowbigImage = (imagelochViewPager_02) findViewById(R.id.vp_lochshowbigImage1);
       mBase_action_bar = (initAction_Bar) findViewById(R.id.base_action_bar);
        mBase_action_bar
                .setMode(initAction_Bar.AUTO_ONCLICK_MODE)
                .setCallBack(new initAction_Bar.Action_bar_call_back() {
                    @Override
                    public void getAction_barView_backbutton(TextView textView) {
                        textView.setText("返回");
                    }

                    @Override
                    public void getAction_barView_backbutton_icon(ImageView imageView) {

                    }

                    @Override
                    public void getAction_barView_title(TextView textView) {
                        textView.setText("放大缩小左右滑动");
                    }

                    @Override
                    public void getAction_barView_right_icon(ImageView imageView) {

                    }
                });
    }
}
